package cn.xingzhen.jfield.helper;

import javax.swing.*;

/**
 * @author wenqiang
 * @date 2023/5/6
 * @comment ..
 */
public class DialogHelper {

    public static void warning(String message) {
        JOptionPane.showMessageDialog(null, message, "警告", JOptionPane.WARNING_MESSAGE);
    }

    public static void error(String message) {
        JOptionPane.showMessageDialog(null, message, "错误", JOptionPane.ERROR_MESSAGE);
    }

    public static void error(Throwable throwable) {
        final StackTraceElement[] st = throwable.getStackTrace();
        String msg = throwable + ": " + throwable.getMessage() + "\n";
        for (int i = 0; i < st.length; i++) {
            msg += st[i].toString() + "\n";
        }
        JOptionPane.showMessageDialog(null, msg, "错误", JOptionPane.ERROR_MESSAGE);
    }

}
